<template>
	<view>
	<scroll-view class="align-center" style="width: 100%; white-space: nowrap;border-bottom: gray 1px solid;"
		scroll-x="true">
		<view class="flex-column text-center" style="width:175rpx;margin-top: 43rpx; float: left;" @click="itemClick(index)" v-for="(item,index) in list" :key="index">
			<view class="color666 font26">{{item.name}}</view>
			<view style="margin: 0 auto; width: 50%; border-bottom: #007BFF 3px solid;" v-if="index==studentIndex"></view>
		</view>
		
	</scroll-view>
	<view class="ddd">
		<uni-list v-if="inqyireList.length" >
				<uni-list-item  v-for="(item,index) in inqyireList" :key="index"
					:ellipsis="1"
					:title="item.vcTitle"
					showArrow
					rightText="查看详情" 
					@click="detail(item.id)" 
					link
				></uni-list-item>
			
		</uni-list>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				studentIndex:0,
				inqyireList:[]
			}
		},
		onLoad() {
			let _this = this;
			console.log(uni.getStorageSync("studentList"))
			uni.getStorageSync("studentList").forEach(it=>{
				_this.list.push({longId:it.user_id,name:it.user_name,show:false,classId:it.class_id});
			})
			if(_this.list.length>0){
			_this.list[0].show=true;
			
			}
			console.log(_this.list)
			_this.getInquire();
		},
		methods: {
			getInquire() {
				let _this = this;
				let opts = {
					url: 'Research/searchBjResearch.shtml'
				};
				let param = {
					xs_id: _this.list[_this.studentIndex].longId
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == '200') {
							_this.inqyireList=res.data.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			},
			itemClick(e)
			{
				console.log(e)
				
				let _this = this;
				_this.studentIndex=e;
				
				let opts = {
					url: 'Research/searchBjResearch.shtml'
				};
				let param = {
					xs_id: _this.list[_this.studentIndex].longId
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == '200') {
							_this.inqyireList=res.data.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			},
			detail(e)
			{
				let _this=this;
				console.log(e)
				uni.navigateTo({
					url:'detail/detail?id='+e+"&studentId="+_this.list[_this.studentIndex].longId
				})
			}
		}
	}
</script>

<style>

</style>
